using System;
using System.Threading;
using System.Threading.Tasks;
using Infrastructure.Log;
using Quartz;

namespace Infrastructure.Quartz
{
    /// <summary>
    /// Quartz调度任务监听器
    /// </summary>
    internal class GlobalSchedulerListener : ISchedulerListener
    {
        public Task JobAdded(IJobDetail jobDetail, CancellationToken cancellationToken = default)
        {
            return Task.Run(() => { });
        }

        public Task JobDeleted(JobKey jobKey, CancellationToken cancellationToken = default)
        {
            return Task.Run(() => { });
        }

        public Task JobInterrupted(JobKey jobKey, CancellationToken cancellationToken = default)
        {
            return Task.Run(() => { });
        }

        public Task JobPaused(JobKey jobKey, CancellationToken cancellationToken = default)
        {
            return Task.Run(() => { });
        }

        public Task JobResumed(JobKey jobKey, CancellationToken cancellationToken = default)
        {
            return Task.Run(() => { });
        }

        public Task JobScheduled(ITrigger trigger, CancellationToken cancellationToken = default)
        {
            return Task.Run(() => LogHelper
                .Information($"Job '{trigger.JobKey.Name}' in group '{trigger.JobKey.Group}' scheduled."));
        }

        public Task JobsPaused(string jobGroup, CancellationToken cancellationToken = default)
        {
            return Task.Run(() => { });
        }

        public Task JobsResumed(string jobGroup, CancellationToken cancellationToken = default)
        {
            return Task.Run(() => { });
        }

        public Task JobUnscheduled(TriggerKey triggerKey, CancellationToken cancellationToken = default)
        {
            return Task.Run(() => { });
        }

        public Task SchedulerError(string msg, SchedulerException cause, CancellationToken cancellationToken = default)
        {
            return Task.Run(() => LogHelper
                .Error($"SchedulerError:the message is '{msg}'.Exception message is '{cause.Message}'", cause));
        }

        public Task SchedulerInStandbyMode(CancellationToken cancellationToken = default)
        {
            return Task.Run(() => { });
        }

        public Task SchedulerShutdown(CancellationToken cancellationToken = default)
        {
            return Task.Run(() => LogHelper.Information("Scheduler shut down."));
        }

        public Task SchedulerShuttingdown(CancellationToken cancellationToken = default)
        {

            return Task.Run(() => LogHelper.Information("Scheduler shutting down."));
        }

        public Task SchedulerStarted(CancellationToken cancellationToken = default)
        {
            return Task.Run(() => LogHelper.Information("Scheduler started."));
        }

        public Task SchedulerStarting(CancellationToken cancellationToken = default)
        {
            return Task.Run(() => LogHelper.Information("Scheduler starting."));
        }

        public Task SchedulingDataCleared(CancellationToken cancellationToken = default)
        {
            return Task.Run(() => { });
        }

        public Task TriggerFinalized(ITrigger trigger, CancellationToken cancellationToken = default)
        {
            return Task.Run(() => { });
        }

        public Task TriggerPaused(TriggerKey triggerKey, CancellationToken cancellationToken = default)
        {
            return Task.Run(() => { });
        }

        public Task TriggerResumed(TriggerKey triggerKey, CancellationToken cancellationToken = default)
        {
            return Task.Run(() => { });
        }

        public Task TriggersPaused(string triggerGroup, CancellationToken cancellationToken = default)
        {
            return Task.Run(() => { });
        }

        public Task TriggersResumed(string triggerGroup, CancellationToken cancellationToken = default)
        {
            return Task.Run(() => { });
        }
    }
}